home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Connections.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  13.0 KB  |  366 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Connections.h
  3.  
  4.      Contains:    Communications Toolbox Connection Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CONNECTIONS__
  21. #define __CONNECTIONS__
  22.  
  23.  
  24. #ifndef __WINDOWS__
  25. #include <Windows.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <Memory.h>                                            */
  30. /*        #include <MixedMode.h>                                    */
  31. /*    #include <Quickdraw.h>                                        */
  32. /*        #include <QuickdrawText.h>                                */
  33. /*    #include <Events.h>                                            */
  34. /*        #include <OSUtils.h>                                    */
  35. /*    #include <Controls.h>                                        */
  36. /*        #include <Menus.h>                                        */
  37.  
  38. #ifndef __DIALOGS__
  39. #include <Dialogs.h>
  40. #endif
  41. /*    #include <Errors.h>                                            */
  42. /*    #include <TextEdit.h>                                        */
  43.  
  44. #ifndef __CTBUTILITIES__
  45. #include <CTBUtilities.h>
  46. #endif
  47. /*    #include <StandardFile.h>                                    */
  48. /*        #include <Files.h>                                        */
  49. /*    #include <AppleTalk.h>                                        */
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if PRAGMA_ALIGN_SUPPORTED
  56. #pragma options align=mac68k
  57. #endif
  58.  
  59. #if PRAGMA_IMPORT_SUPPORTED
  60. #pragma import on
  61. #endif
  62.  
  63.  
  64. enum {
  65. /*    current Connection Manager version    */
  66.     curCMVersion                = 2,
  67. /*    current Connection Manager Environment Record version     */
  68.     curConnEnvRecVers            = 0,
  69. /* CMErr */
  70.     cmGenericError                = -1,
  71.     cmNoErr                        = 0,
  72.     cmRejected                    = 1,
  73.     cmFailed                    = 2,
  74.     cmTimeOut                    = 3,
  75.     cmNotOpen                    = 4,
  76.     cmNotClosed                    = 5,
  77.     cmNoRequestPending            = 6,
  78.     cmNotSupported                = 7,
  79.     cmNoTools                    = 8,
  80.     cmUserCancel                = 9,
  81.     cmUnknownError                = 11
  82. };
  83.  
  84. typedef OSErr CMErr;
  85.  
  86.  
  87. enum {
  88.     cmData                        = 1L << 0,
  89.     cmCntl                        = 1L << 1,
  90.     cmAttn                        = 1L << 2,
  91.     cmDataNoTimeout                = 1L << 4,
  92.     cmCntlNoTimeout                = 1L << 5,
  93.     cmAttnNoTimeout                = 1L << 6,
  94.     cmDataClean                    = 1L << 8,
  95.     cmCntlClean                    = 1L << 9,
  96.     cmAttnClean                    = 1L << 10,
  97. /*        Only for CMRecFlags (not CMChannel) in the rest of this enum    */
  98.     cmNoMenus                    = 1L << 16,
  99.     cmQuiet                        = 1L << 17,
  100.     cmConfigChanged                = 1L << 18
  101. };
  102.  
  103. /* CMRecFlags and CMChannel        */
  104. /*        Low word of CMRecFlags is same as CMChannel    */
  105. typedef long CMRecFlags;
  106.  
  107. typedef short CMChannel;
  108.  
  109.  
  110. enum {
  111.     cmStatusOpening                = 1L << 0,
  112.     cmStatusOpen                = 1L << 1,
  113.     cmStatusClosing                = 1L << 2,
  114.     cmStatusDataAvail            = 1L << 3,
  115.     cmStatusCntlAvail            = 1L << 4,
  116.     cmStatusAttnAvail            = 1L << 5,
  117.     cmStatusDRPend                = 1L << 6,                        /* data read pending    */
  118.     cmStatusDWPend                = 1L << 7,                        /* data write pending    */
  119.     cmStatusCRPend                = 1L << 8,                        /* cntl read pending    */
  120.     cmStatusCWPend                = 1L << 9,                        /* cntl write pending    */
  121.     cmStatusARPend                = 1L << 10,                        /* attn read pending    */
  122.     cmStatusAWPend                = 1L << 11,                        /* attn write pending    */
  123.     cmStatusBreakPend            = 1L << 12,
  124.     cmStatusListenPend            = 1L << 13,
  125.     cmStatusIncomingCallPresent    = 1L << 14,
  126.     cmStatusReserved0            = 1L << 15
  127. };
  128.  
  129. typedef unsigned long CMStatFlags;
  130.  
  131.  
  132. enum {
  133.     cmDataIn,
  134.     cmDataOut,
  135.     cmCntlIn,
  136.     cmCntlOut,
  137.     cmAttnIn,
  138.     cmAttnOut,
  139.     cmRsrvIn,
  140.     cmRsrvOut
  141. };
  142.  
  143. typedef unsigned short CMBufFields;
  144.  
  145. typedef Ptr CMBuffers[8];
  146.  
  147. typedef long CMBufferSizes[8];
  148.  
  149. typedef const long *ConstCMBufferSizesParam;
  150.  
  151.  
  152. enum {
  153.     cmSearchSevenBit            = 1L << 0
  154. };
  155.  
  156. typedef unsigned short CMSearchFlags;
  157.  
  158.  
  159. enum {
  160.     cmFlagsEOM                    = 1L << 0
  161. };
  162.  
  163. typedef unsigned short CMFlags;
  164.  
  165. struct ConnEnvironRec {
  166.     short                            version;
  167.     long                            baudRate;
  168.     short                            dataBits;
  169.     CMChannel                        channels;
  170.     Boolean                            swFlowControl;
  171.     Boolean                            hwFlowControl;
  172.     CMFlags                            flags;
  173. };
  174. typedef struct ConnEnvironRec ConnEnvironRec;
  175.  
  176. typedef ConnEnvironRec *ConnEnvironRecPtr;
  177.  
  178. typedef struct ConnRecord ConnRecord, *ConnPtr, **ConnHandle;
  179.  
  180. typedef pascal long (*ConnectionToolDefProcPtr)(ConnHandle hConn, short msg, long p1, long p2, long p3);
  181. typedef pascal void (*ConnectionSearchCallBackProcPtr)(ConnHandle hConn, Ptr matchPtr, long refNum);
  182. typedef pascal void (*ConnectionCompletionProcPtr)(ConnHandle hConn);
  183. typedef pascal void (*ConnectionChooseIdleProcPtr)(void);
  184.  
  185. #if GENERATINGCFM
  186. typedef UniversalProcPtr ConnectionToolDefUPP;
  187. typedef UniversalProcPtr ConnectionSearchCallBackUPP;
  188. typedef UniversalProcPtr ConnectionCompletionUPP;
  189. typedef UniversalProcPtr ConnectionChooseIdleUPP;
  190. #else
  191. typedef ConnectionToolDefProcPtr ConnectionToolDefUPP;
  192. typedef ConnectionSearchCallBackProcPtr ConnectionSearchCallBackUPP;
  193. typedef ConnectionCompletionProcPtr ConnectionCompletionUPP;
  194. typedef ConnectionChooseIdleProcPtr ConnectionChooseIdleUPP;
  195. #endif
  196.  
  197. struct ConnRecord {
  198.     short                            procID;
  199.     CMRecFlags                        flags;
  200.     CMErr                            errCode;
  201.     long                            refCon;
  202.     long                            userData;
  203.     ConnectionToolDefUPP            defProc;
  204.     Ptr                                config;
  205.     Ptr                                oldConfig;
  206.     long                            asyncEOM;
  207.     long                            reserved1;
  208.     long                            reserved2;
  209.     Ptr                                cmPrivate;
  210.     CMBuffers                        bufferArray;
  211.     CMBufferSizes                    bufSizes;
  212.     long                            mluField;
  213.     CMBufferSizes                    asyncCount;
  214. };
  215.  
  216. enum {
  217. /* CMIOPB constants and structure */
  218.     cmIOPBQType                    = 10,
  219.     cmIOPBversion                = 0
  220. };
  221.  
  222. struct CMIOPB {
  223.     QElemPtr                        qLink;
  224.     short                            qType;                        /* cmIOPBQType */
  225.     ConnHandle                        hConn;
  226.     Ptr                                theBuffer;
  227.     long                            count;
  228.     CMFlags                            flags;
  229.     ConnectionCompletionUPP            userCompletion;
  230.     long                            timeout;
  231.     CMErr                            errCode;
  232.     CMChannel                        channel;
  233.     long                            asyncEOM;
  234.     long                            reserved1;
  235.     short                            reserved2;
  236.     short                            version;                    /* cmIOPBversion */
  237.     long                            refCon;                        /* for application */
  238.     long                            toolData1;                    /* for tool */
  239.     long                            toolData2;                    /* for tool */
  240. };
  241. typedef struct CMIOPB CMIOPB;
  242.  
  243. typedef CMIOPB *CMIOPBPtr;
  244.  
  245. enum {
  246.     uppConnectionToolDefProcInfo = kPascalStackBased
  247.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  248.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle)))
  249.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  250.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  251.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  252.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  253.     uppConnectionSearchCallBackProcInfo = kPascalStackBased
  254.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle)))
  255.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  256.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))),
  257.     uppConnectionCompletionProcInfo = kPascalStackBased
  258.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle))),
  259.     uppConnectionChooseIdleProcInfo = kPascalStackBased
  260. };
  261.  
  262. #if GENERATINGCFM
  263. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3)        \
  264.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionToolDefProcInfo, (hConn), (msg), (p1), (p2), (p3))
  265. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum)        \
  266.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, (hConn), (matchPtr), (refNum))
  267. #define CallConnectionCompletionProc(userRoutine, hConn)        \
  268.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionCompletionProcInfo, (hConn))
  269. #define CallConnectionChooseIdleProc(userRoutine)        \
  270.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo)
  271. #else
  272. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3)        \
  273.         (*(userRoutine))((hConn), (msg), (p1), (p2), (p3))
  274. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum)        \
  275.         (*(userRoutine))((hConn), (matchPtr), (refNum))
  276. #define CallConnectionCompletionProc(userRoutine, hConn)        \
  277.         (*(userRoutine))((hConn))
  278. #define CallConnectionChooseIdleProc(userRoutine)        \
  279.         (*(userRoutine))()
  280. #endif
  281.  
  282. #if GENERATINGCFM
  283. #define NewConnectionToolDefProc(userRoutine)        \
  284.         (ConnectionToolDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionToolDefProcInfo, GetCurrentArchitecture())
  285. #define NewConnectionSearchCallBackProc(userRoutine)        \
  286.         (ConnectionSearchCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, GetCurrentArchitecture())
  287. #define NewConnectionCompletionProc(userRoutine)        \
  288.         (ConnectionCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionCompletionProcInfo, GetCurrentArchitecture())
  289. #define NewConnectionChooseIdleProc(userRoutine)        \
  290.         (ConnectionChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo, GetCurrentArchitecture())
  291. #else
  292. #define NewConnectionToolDefProc(userRoutine)        \
  293.         ((ConnectionToolDefUPP) (userRoutine))
  294. #define NewConnectionSearchCallBackProc(userRoutine)        \
  295.         ((ConnectionSearchCallBackUPP) (userRoutine))
  296. #define NewConnectionCompletionProc(userRoutine)        \
  297.         ((ConnectionCompletionUPP) (userRoutine))
  298. #define NewConnectionChooseIdleProc(userRoutine)        \
  299.         ((ConnectionChooseIdleUPP) (userRoutine))
  300. #endif
  301.  
  302. extern pascal CMErr InitCM(void);
  303. extern pascal Handle CMGetVersion(ConnHandle hConn);
  304. extern pascal short CMGetCMVersion(void);
  305. extern pascal ConnHandle CMNew(short procID, CMRecFlags flags, ConstCMBufferSizesParam desiredSizes, long refCon, long userData);
  306. extern pascal void CMDispose(ConnHandle hConn);
  307. extern pascal CMErr CMListen(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout);
  308. extern pascal CMErr CMAccept(ConnHandle hConn, Boolean accept);
  309. extern pascal CMErr CMOpen(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout);
  310. extern pascal CMErr CMClose(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout, Boolean now);
  311. extern pascal CMErr CMAbort(ConnHandle hConn);
  312. extern pascal CMErr CMStatus(ConnHandle hConn, CMBufferSizes sizes, CMStatFlags *flags);
  313. extern pascal void CMIdle(ConnHandle hConn);
  314. extern pascal void CMReset(ConnHandle hConn);
  315. extern pascal void CMBreak(ConnHandle hConn, long duration, Boolean async, ConnectionCompletionUPP completor);
  316. extern pascal CMErr CMRead(ConnHandle hConn, void *theBuffer, long *toRead, CMChannel theChannel, Boolean async, ConnectionCompletionUPP completor, long timeout, CMFlags *flags);
  317. extern pascal CMErr CMWrite(ConnHandle hConn, const void *theBuffer, long *toWrite, CMChannel theChannel, Boolean async, ConnectionCompletionUPP completor, long timeout, CMFlags flags);
  318. extern pascal CMErr CMIOKill(ConnHandle hConn, short which);
  319. extern pascal void CMActivate(ConnHandle hConn, Boolean activate);
  320. extern pascal void CMResume(ConnHandle hConn, Boolean resume);
  321. extern pascal Boolean CMMenu(ConnHandle hConn, short menuID, short item);
  322. extern pascal Boolean CMValidate(ConnHandle hConn);
  323. extern pascal void CMDefault(Ptr *theConfig, short procID, Boolean allocate);
  324. extern pascal Handle CMSetupPreflight(short procID, long *magicCookie);
  325. extern pascal Boolean CMSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  326. extern pascal void CMSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  327. extern pascal void CMSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  328. extern pascal void CMSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  329. extern pascal void CMSetupPostflight(short procID);
  330. extern pascal Ptr CMGetConfig(ConnHandle hConn);
  331. extern pascal short CMSetConfig(ConnHandle hConn, const void *thePtr);
  332. extern pascal OSErr CMIntlToEnglish(ConnHandle hConn, const void *inputPtr, Ptr *outputPtr, short language);
  333. extern pascal OSErr CMEnglishToIntl(ConnHandle hConn, const void *inputPtr, Ptr *outputPtr, short language);
  334. extern pascal long CMAddSearch(ConnHandle hConn, ConstStr255Param theString, CMSearchFlags flags, ConnectionSearchCallBackUPP callBack);
  335. extern pascal void CMRemoveSearch(ConnHandle hConn, long refnum);
  336. extern pascal void CMClearSearch(ConnHandle hConn);
  337. extern pascal CMErr CMGetConnEnvirons(ConnHandle hConn, ConnEnvironRec *theEnvirons);
  338. extern pascal short CMChoose(ConnHandle *hConn, Point where, ConnectionChooseIdleUPP idle);
  339. extern pascal void CMEvent(ConnHandle hConn, const EventRecord *theEvent);
  340. extern pascal void CMGetToolName(short procID, Str255 name);
  341. extern pascal short CMGetProcID(ConstStr255Param name);
  342. extern pascal void CMSetRefCon(ConnHandle hConn, long refCon);
  343. extern pascal long CMGetRefCon(ConnHandle hConn);
  344. extern pascal long CMGetUserData(ConnHandle hConn);
  345. extern pascal void CMSetUserData(ConnHandle hConn, long userData);
  346. extern pascal void CMGetErrorString(ConnHandle hConn, short id, Str255 errMsg);
  347. extern pascal CMErr CMNewIOPB(ConnHandle hConn, CMIOPBPtr *theIOPB);
  348. extern pascal CMErr CMDisposeIOPB(ConnHandle hConn, CMIOPBPtr theIOPB);
  349. extern pascal CMErr CMPBRead(ConnHandle hConn, CMIOPBPtr theIOPB, Boolean async);
  350. extern pascal CMErr CMPBWrite(ConnHandle hConn, CMIOPBPtr theIOPB, Boolean async);
  351. extern pascal CMErr CMPBIOKill(ConnHandle hConn, CMIOPBPtr theIOPB);
  352.  
  353. #if PRAGMA_IMPORT_SUPPORTED
  354. #pragma import off
  355. #endif
  356.  
  357. #if PRAGMA_ALIGN_SUPPORTED
  358. #pragma options align=reset
  359. #endif
  360.  
  361. #ifdef __cplusplus
  362. }
  363. #endif
  364.  
  365. #endif /* __CONNECTIONS__ */
  366.